package com.shijimo.file.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Dream_飞翔
 * @date 2021/11/9
 * @time 20:02
 * @email 1072876976@qq.com
 */

@Configuration
public class SpringMvcConfig implements WebMvcConfigurer {
    @Value("${file.path}")
    private String FILE_PATH;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 所有带 "/f" 的请求都认为是静态资源请求
        // http://127.0.0.1:9003/file/f/teacher/oxhf8QZ2-header.jpg
        registry.addResourceHandler("/f/**").addResourceLocations("file:" + FILE_PATH);
    }
}
